package org.haredot.web;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * 请求映射处理器
 */
public class RequestMappingHandler {

    /**
     * 根据映射地址和请求方式 获取 RequestMapping
     * @param urlPattern
     * @param requestMappings
     * @return
     */
    public static List<RequestMapping> parseUrlPattern(String urlPattern, List<RequestMapping> requestMappings) {
        return requestMappings.stream()
                .filter(mapping -> Objects.equals(mapping.getUrlPattern(), urlPattern))
                .collect(Collectors.toList());
    }
}
